<script setup>
import { onMounted, ref } from 'vue';
const props = defineProps(['drawer'])
const userInfo = JSON.parse(localStorage.getItem("ZAYY_USER_INFO"))
const menuInfo = JSON.parse(localStorage.getItem("ZAYY_MENU_INFO"))
const menuIds = JSON.parse(localStorage.getItem("ZAYY_MENU_IDS"))

onMounted(() => {})

function isMenu(id) {
    let sum = 0
    menuIds.forEach(item => {
        if(item == id) {
            sum ++
        }
    })
    return sum
}
</script>

<template>
    <v-navigation-drawer color="#eee" :permanent="true" v-model="props.drawer" style="width: 275px;">
        <v-card>
            <v-list>
                <v-list-item
                    :title="userInfo.username"
                >
                </v-list-item>
                <v-list-group value="系统管理" v-if="isMenu(1)">
                    <template v-slot:activator="{ props }">
                        <v-list-item v-bind="props" prepend-icon="mdi-cog" title="系统管理"></v-list-item>
                    </template>
                    <v-list-item v-if="isMenu(2)" title="角色管理" to="role"></v-list-item>
                    <v-list-item v-if="isMenu(8)" title="用户管理" to="user"></v-list-item>
                    <v-list-item v-if="isMenu(35)" title="日志管理" to="log"></v-list-item>
                </v-list-group>

                <v-list-group value="药品返点基础资料" v-if="isMenu(15)">
                    <template v-slot:activator="{ props }">
                        <v-list-item v-bind="props" prepend-icon="mdi-information" title="药品返点基础资料"></v-list-item>
                    </template>
                    <v-list-item v-if="isMenu(16)" title="药品基础资料" to="medicine_base_info"></v-list-item>
                    <v-list-item v-if="isMenu(24)" title="药品基础资料历史记录" to="medicine_history"></v-list-item>
                </v-list-group>

                <v-list-group value="药品返点基础资料管理" v-if="isMenu(26)">
                    <template v-slot:activator="{ props }">
                        <v-list-item v-bind="props" prepend-icon="mdi-access-point" title="药品返点基础资料管理"></v-list-item>
                    </template>
                    <v-list-item v-if="isMenu(27)" title="药品返点基础资料" to="medicine_point_base_info"></v-list-item>
                    <v-list-item v-if="isMenu(37)" title="药品返点基础资料历史记录" to="medicine_point_history"></v-list-item>
                </v-list-group>

                <v-list-item prepend-icon="mdi-face-agent" title="药品返点计算清单" to="medicine_point_calc" v-if="isMenu(39)"></v-list-item>

                <v-list-group value="返点记录管理" v-if="isMenu(42)">
                    <template v-slot:activator="{ props }">
                        <v-list-item v-bind="props" prepend-icon="mdi-forum" title="返点记录管理"></v-list-item>
                    </template>
                    <v-list-item v-if="isMenu(43)" title="返点记录" to="medicine_order"></v-list-item>
                    <v-list-item v-if="isMenu(47)" title="返点记录历史记录" to="medicine_order_record"></v-list-item>
                </v-list-group>

                <v-list-group value="实返管理" v-if="isMenu(51)">
                    <template v-slot:activator="{ props }">
                        <v-list-item v-bind="props" prepend-icon="mdi-book-open-blank-variant" title="实返管理"></v-list-item>
                    </template>
                    <v-list-item v-if="isMenu(52)" title="按清单记录" to="medicine_order_register"></v-list-item>
                    <v-list-item v-if="isMenu(56)" title="按供应商记录" to="medicine_supplier_register"></v-list-item>
                </v-list-group>

                <v-list-group value="实返记录" v-if="isMenu(59)">
                    <template v-slot:activator="{ props }">
                        <v-list-item v-bind="props" prepend-icon="mdi-book-edit" title="实返记录"></v-list-item>
                    </template>
                    <v-list-item v-if="isMenu(60)" title="按清单实返记录" to="medicine_register_record_order"></v-list-item>
                    <v-list-item v-if="isMenu(63)" title="按供应商实返记录" to="medicine_supplier_record"></v-list-item>
                </v-list-group>

                <v-list-group value="报表管理" v-if="isMenu(65)">
                    <template v-slot:activator="{ props }">
                        <v-list-item v-bind="props" prepend-icon="mdi-television" title="报表管理"></v-list-item>
                    </template>
                    <v-list-item v-if="isMenu(66)" title="清单返点统计" to="medicine_order_report"></v-list-item>
                    <v-list-item v-if="isMenu(68)" title="供应商返点统计" to="medicine_point_report"></v-list-item>
                </v-list-group>
            </v-list>

            <v-divider></v-divider>

            <!-- <v-list-group v-for="item in menuInfo" :value="item.menuName">
                <template v-slot:activator="{ props }">
                    <v-list-item v-bind="props" prepend-icon="mdi-cog" :title="item.menuName" v-show="item.isShow" :to="item.isMenu ? item.icon : ''"></v-list-item>
                </template>
                <v-list-item v-for="k in item.children" :prepend-icon="'mdi-' + k.icon" :title="k.menuName" :to="k.icon" v-show="k.isShow"></v-list-item>
            </v-list-group> -->

        </v-card>
    </v-navigation-drawer>
    <v-main :scrollable="true">
        <router-view></router-view>
    </v-main>
</template>

<style scoped lang="scss">
:deep(.v-list-item-title) {
    font-size: 15px;
}
:deep(.v-list-item__prepend) {
    width: 30px;
}
</style>
